#pragma once
//============================================================================
// Copyright (C) 2013 Brett R. Jones
//
// Issued to public domain 2013
//
// brettjones1900@gmail.com
// http://www.p2panarchy.com
//============================================================================

#include <string>
#include "VxDefs.h"

class VxUrl 
{
public:
	//=== vars ===//
	std::string			m_strUrl;
	std::string			m_strProtocol;
	std::string			m_strHost;
	U16					m_u16Port;
	std::string			m_strPath;
	std::string			m_strUser;
	std::string			m_strPassword;

	std::string			m_strQuery;
	std::string			m_strFragment;

public:
	VxUrl();
	VxUrl( const char * pUrl );

	void			setUrl( const char * pUrl );
	const char *	getUrl( void );

	const char *	getProtocol( void );

	const char *	getUser( void );
	const char *	getPassword( void );

	const char *	getHost( void );
	U16				getPort( void );
	void			setPath( const char * pFilePathAndName );
	const char *	getPath( void );
	const char *	getQuery( void );
	const char *	getFragment( void );

	bool			isAbsoluteUrl();
	const char *	getRelativeURL( std::string& strRetRelativeUrl, bool bWithParam = false );
	const char *	getAbsoluteURL( std::string& strRetAbsoluteUrl );
	const char *	getHostURL( const char * host, int port, const char * uri, std::string& buf );
};
